/**
 * @作者 faner
 * @创建时间 2021/1/11 15:36
 */
package com.faner.fast.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 初始化赋值全局调用
 */
@Component
public class ValueUtil {

    public static String tokenHeader;
    public static String tokenHead;
    public static Boolean singleLogin;
    /** 在线用户 key，根据 key 查询 redis 中在线用户的数据 */
    public static String onlineKey;
    //JWT的超期限时间(60*60*24*7)
    public static Long expiration;

    @Value("${jwt.tokenHeader}")
    private String tokenHeaderValue;
    @Value("${jwt.tokenHead}")
    private String tokenHeadValue;
    @Value("${single.login}")
    private Boolean singleLoginValue;
    @Value("${jwt.onlineKey}")
    private String onlineKeyValue;
    @Value("${jwt.expiration}")
    private Long expirationValue;

    @PostConstruct
    public void setValue() {
       this.tokenHeader = tokenHeaderValue;
       this.tokenHead = tokenHeadValue;
       this.singleLogin = singleLoginValue;
       this.onlineKey = onlineKeyValue;
       this.expiration = expirationValue;
    }
}
